package logic

import (
	"context"
	"time"
	"weee/models"

	"weee/userrpc/internal/svc"
	"weee/userrpc/userrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type SendCodeLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewSendCodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SendCodeLogic {
	return &SendCodeLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// SendCode todo: 发送短信验证码
func (l *SendCodeLogic) SendCode(in *userrpc.SendCodeRequest) (*userrpc.SendCodeResponse, error) {
	// todo: add your logic here and delete this line
	SendCode := "send_code:" + in.Mobile
	models.Redis.Set(context.Background(), SendCode, in.Code, time.Minute*3)
	return &userrpc.SendCodeResponse{
		Code: 200,
		Msg:  "发送验证码成功",
		Data: in.Code,
	}, nil
}
